﻿// AIParamDebug.cpp: 实现文件
//
#include "stdafx.h"
#include "DefectInspectionSystem.h"
#include "AIParamDebug.h"
#include "afxdialogex.h"
#include "DefectInspectionSystemDlg.h"

// AIParamDebug 对话框

IMPLEMENT_DYNAMIC(AIParamDebug, CDialogEx)

AIParamDebug::AIParamDebug(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_DIALOG_AIDEBUG, pParent)
	, m_anoImageGray(0)
	, m_area(0)
{

}

AIParamDebug::~AIParamDebug()
{
}

void AIParamDebug::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Text(pDX, IDC_STATICGray, m_anoImageGray);
	DDX_Text(pDX, IDC_STATICArea, m_area);
}

BOOL AIParamDebug::OnInitDialog()
{
	InitHalconWindow();
	((CButton*)GetDlgItem(IDC_RADIO1))->SetCheck(TRUE); //选上
	LoadAnoParams();
	return 0;
}

void AIParamDebug::InitHalconWindow()
{
	CWnd* pwnd = GetDlgItem(IDC_ORIWIN);
	m_oriWin.openWindow(pwnd);

	CWnd* pwnd2 = GetDlgItem(IDC_ANOWIN);
	m_AnoWin.openWindow(pwnd2);

	CWnd* pwnd3 = GetDlgItem(IDC_RESULTWIN);
	m_ResultWin.openWindow(pwnd3);
}


BEGIN_MESSAGE_MAP(AIParamDebug, CDialogEx)
	ON_WM_MOUSEWHEEL()
	ON_BN_CLICKED(IDC_BUTTON20, &AIParamDebug::OnBnClickedButton20)
	ON_BN_CLICKED(IDC_BUTTONNEXT, &AIParamDebug::OnBnClickedButtonnext)
	ON_BN_CLICKED(IDC_BUTTONPREVIOUS, &AIParamDebug::OnBnClickedButtonprevious)
	ON_BN_CLICKED(IDC_RADIO1, &AIParamDebug::OnBnClickedRadio1)
	ON_BN_CLICKED(IDC_RADIO7, &AIParamDebug::OnBnClickedRadio7)
	ON_BN_CLICKED(IDC_BUTTON_SaveParam, &AIParamDebug::OnBnClickedButtonSaveparam)
	ON_BN_CLICKED(IDC_BUTTON1, &AIParamDebug::OnBnClickedButton1)
	ON_BN_CLICKED(IDC_BUTTON22, &AIParamDebug::OnBnClickedButton22)
	ON_BN_CLICKED(IDC_BUTTON23, &AIParamDebug::OnBnClickedButton23)
	ON_BN_CLICKED(IDC_BUTTON24, &AIParamDebug::OnBnClickedButton24)
	ON_BN_CLICKED(IDC_BUTTON25, &AIParamDebug::OnBnClickedButton25)
	ON_BN_CLICKED(IDC_BUTTON26, &AIParamDebug::OnBnClickedButton26)
	ON_BN_CLICKED(IDC_BUTTON27, &AIParamDebug::OnBnClickedButton27)
	ON_BN_CLICKED(IDC_BUTTON28, &AIParamDebug::OnBnClickedButton28)
	ON_BN_CLICKED(IDC_BUTTON29, &AIParamDebug::OnBnClickedButton29)
END_MESSAGE_MAP()

// AIParamDebug 消息处理程序
void AIParamDebug::OnBnClickedButton20()
{
	// TODO: 在此添加控件通知处理程序代码
	CFolderPickerDialog dlg_folder;
	if (dlg_folder.DoModal() == IDOK)
	{
		testImagesPath = dlg_folder.GetPathName();
		SetDlgItemText(IDC_EditLoadTestImagesPath, testImagesPath);
		if (testImagesPath != "")
		{
			int startendflag;
			HTuple imageSize = MfcHalconWin::ReadImages(MfcHalconWin::CString2HTuple(testImagesPath));
			HTuple path = MfcHalconWin::ReadImages(1, startendflag);
			HalconCpp::ReadImage(&img, path);
			m_oriWin.dispObj(img);
			m_oriWin.flushWindow();

			CString imageNumText;
			imageNumText.Format("%d/%d", MfcHalconWin::m_currentImageIndex+1, MfcHalconWin::m_currentImageSize);
			GetDlgItem(IDC_TEXT)->SetWindowTextA(imageNumText);
			
			if (startendflag == 1)
			{
				//最后一张了
				GetDlgItem(IDC_BUTTONNEXT)->EnableWindow(FALSE);
				GetDlgItem(IDC_BUTTONPREVIOUS)->EnableWindow(FALSE);
				return;
			}
			else
			{
				GetDlgItem(IDC_BUTTONNEXT)->EnableWindow(TRUE);
				GetDlgItem(IDC_BUTTONPREVIOUS)->EnableWindow(FALSE);
			}
			detect();
		}
	}
}

void AIParamDebug::detect()
{
	if (isFront)
	{
		detectFront();
	}
	else
	{
		detectBack();
	}
}

void AIParamDebug::detectFront()
{
	CDefectInspectionSystemDlg* pDia = CDefectInspectionSystemDlg::s_pDialog;
	HObject ho_RegionCompareDefectFront, ho_RegionEdgeDefectFront, ho_RegionProduct, ho_AiImage, ho_region;
	GenEmptyObj(&ho_AiImage);
	GenEmptyRegion(&ho_region);
	HTuple hv_NumCompareFront, hv_NumEdgeFront;
	int flag;
	pDia->m_halconTool.DetectFront(pDia->m_hvHalconWindowFront, img, pDia->ho_RegionCompareFront, pDia->ho_RegionModelFront, pDia->m_paramDetect_Front, pDia->dll_instanceFront, &ho_RegionCompareDefectFront,
		&ho_RegionEdgeDefectFront, &hv_NumCompareFront, &hv_NumEdgeFront, &flag, &ho_RegionProduct, &ho_AiImage, ho_region, 1);
	m_AnoWin.clearWindow();
	m_AnoWin.dispObj(ho_AiImage);
	m_AnoWin.flushWindow();

	m_ResultWin.dispObj(img);

	HObject ho_ConnectedRegions, ho_RegionsCompareDefect, ho_singleBigRegions, ho_ConnectedRegionsTemp;
	SelectShape(ho_region, &ho_ConnectedRegions, "area", "and", HTuple(pDia->m_paramDetect_Front.ABN_Single_Area), 9999999);
	Union1(ho_ConnectedRegions, &ho_ConnectedRegionsTemp);
	SelectShape(ho_ConnectedRegionsTemp, &ho_RegionsCompareDefect, "area", "and", HTuple(pDia->m_paramDetect_Front.ABN_ALL_Area), 99999999);
	Intersection(ho_ConnectedRegions,ho_RegionsCompareDefect, &ho_RegionsCompareDefect);
 
	//提取单个最大面积
	SelectShape(ho_region, &ho_singleBigRegions, "area", "and", HTuple(pDia->m_paramDetect_Front.ABN_Single_Big_Area), 9999999);
	//Union1(ho_singleBigRegions, &ho_singleBigRegions);
	//Union2(ho_singleBigRegions, ho_RegionsCompareDefect, &ho_RegionsCompareDefect);
	ConcatObj(ho_singleBigRegions, ho_RegionsCompareDefect, &ho_RegionsCompareDefect);

	//HalconCpp::Connection(ho_RegionsCompareDefect,&ho_RegionsCompareDefect);
	m_ResultWin.dispObj(ho_RegionsCompareDefect);
	m_ResultWin.flushWindow();
}

void AIParamDebug::detectBack()
{
	CDefectInspectionSystemDlg* pDia = CDefectInspectionSystemDlg::s_pDialog;
	HObject ho_RegionCompareDefectBack, ho_RegionEdgeDefectBack, ho_RegionProduct, ho_AiImage, ho_region;
	GenEmptyObj(&ho_AiImage);
	GenEmptyRegion(&ho_region);
	HTuple hv_NumCompareBack, hv_NumEdgeBack;
	int flag;
	
	pDia->m_halconTool.DetectBack(pDia->m_hvHalconWindow, img, pDia->ho_RegionCompare, pDia->ho_RegionModel, pDia->m_paramDetect_Back, pDia->dll_instanceBack, &ho_RegionEdgeDefectBack,
		&ho_RegionEdgeDefectBack, &hv_NumCompareBack, &hv_NumEdgeBack, &flag, &ho_RegionProduct, &ho_AiImage, ho_region, 1);
	m_AnoWin.clearWindow();
	m_AnoWin.dispObj(ho_AiImage);
	m_AnoWin.flushWindow();

	m_ResultWin.dispObj(img);
	m_ResultWin.dispObj(ho_region);
	m_ResultWin.flushWindow();

}

void AIParamDebug::LoadAnoParams(bool isFront)
{
	CDefectInspectionSystemDlg* pDia = CDefectInspectionSystemDlg::s_pDialog;
	char tmpstr[MAX_PATH];
	int tempInt;
	if (isFront)
	{
		//正面
		//异常阈值
		GetPrivateProfileString("DFront", "ABN_DEF_Thresh", "0", tmpstr, MAX_PATH, theApp.m_strFilePath + "\\System-" + pDia->m_strCurrentCupType + ".ini");
		tempInt = std::atoi(tmpstr);
		SetDlgItemInt(IDC_EDIT_DEF_THRESH, tempInt);
		
		//单个最大面积
		GetPrivateProfileString("DFront", "ABN_Single_Big_Area", "0", tmpstr, MAX_PATH, theApp.m_strFilePath + "\\System-" + pDia->m_strCurrentCupType + ".ini");
		tempInt = std::atoi(tmpstr);
		SetDlgItemInt(IDC_EDITSingleBigArea, tempInt);
		
		//单个最小面积
		GetPrivateProfileString("DFront", "ABN_Single_Area", "0", tmpstr, MAX_PATH, theApp.m_strFilePath + "\\System-" + pDia->m_strCurrentCupType + ".ini");
		tempInt = std::atoi(tmpstr);
		SetDlgItemInt(IDC_EDITSingleArea, tempInt);

		//总面积
		GetPrivateProfileString("DFront", "ABN_ALL_AREA", "0", tmpstr, MAX_PATH, theApp.m_strFilePath + "\\System-" + pDia->m_strCurrentCupType + ".ini");
		tempInt = std::atoi(tmpstr);
		SetDlgItemInt(IDC_EDIT_ALL_Area, tempInt);

		//内缩半径
		GetPrivateProfileString("DFront", "AiErosion", "0", tmpstr, MAX_PATH, theApp.m_strFilePath + "\\System-" + pDia->m_strCurrentCupType + ".ini");
		tempInt = std::atoi(tmpstr);
		SetDlgItemInt(IDC_EDIT_AiErosion, tempInt);
		
	}
	else
	{
		//反面
		GetPrivateProfileString("DBack", "ABN_DEF_Thresh", "0", tmpstr, MAX_PATH, theApp.m_strFilePath + "\\System-" + pDia->m_strCurrentCupType + ".ini");
		tempInt = std::atoi(tmpstr);
		SetDlgItemInt(IDC_EDIT_DEF_THRESH, tempInt);

		//单个最大面积
		GetPrivateProfileString("DBack", "ABN_Single_Big_Area", "0", tmpstr, MAX_PATH, theApp.m_strFilePath + "\\System-" + pDia->m_strCurrentCupType + ".ini");
		tempInt = std::atoi(tmpstr);
		SetDlgItemInt(IDC_EDITSingleBigArea, tempInt);

		//单个最小面积
		GetPrivateProfileString("DBack", "ABN_Single_Area", "0", tmpstr, MAX_PATH, theApp.m_strFilePath + "\\System-" + pDia->m_strCurrentCupType + ".ini");
		tempInt = std::atoi(tmpstr);
		SetDlgItemInt(IDC_EDITSingleArea, tempInt);

		//总面积
		GetPrivateProfileString("DBack", "ABN_ALL_AREA", "0", tmpstr, MAX_PATH, theApp.m_strFilePath + "\\System-" + pDia->m_strCurrentCupType + ".ini");
		tempInt = std::atoi(tmpstr);
		SetDlgItemInt(IDC_EDIT_ALL_Area, tempInt);

		//内缩半径
		GetPrivateProfileString("DBack", "AiErosion", "0", tmpstr, MAX_PATH, theApp.m_strFilePath + "\\System-" + pDia->m_strCurrentCupType + ".ini");
		tempInt = std::atoi(tmpstr);
		SetDlgItemInt(IDC_EDIT_AiErosion, tempInt);
	}
}

BOOL AIParamDebug::PreTranslateMessage(MSG* pMsg)
{
	//取得屏幕区鼠标位置
	POINT ptTmp;
	GetCursorPos(&ptTmp);

	//得到图像控件在屏幕上的坐标
	//得到Picture control控件的指针
	CWnd* pPicWnd = GetDlgItem(IDC_ORIWIN);
	CRect RectPicInScreen;
	memset(RectPicInScreen, 0, sizeof(CRect));   //将结构体清0
	pPicWnd->GetWindowRect(RectPicInScreen);

	try
	{
		//矩形规范化 底边大于顶边 右边大于左边
		RectPicInScreen.NormalizeRect();
		//判断鼠标是否在HalconWin内部
		if (RectPicInScreen.PtInRect(ptTmp))
		{
			//移动模式
			if (m_oriWin.m_mfcHalconWinModel == MfcHalconWin::MOVE)
			{
				//左键按住会进
				if (pMsg->wParam == MK_LBUTTON)
				{
					//移动图像
					m_oriWin.translationImage();
				}
				//左键没按住
				if (!pMsg->wParam == MK_LBUTTON)
				{
					//清理移动轨迹
					m_oriWin.m_movedPoint.clear();
					m_oriWin.m_movedPoint.shrink_to_fit();
				}
			}
		}
	}
	catch (...)
	{
	}

	//中间图
	//得到图像控件在屏幕上的坐标
	//得到Picture control控件的指针
	CWnd* pPicWndAno = GetDlgItem(IDC_ANOWIN);
	CRect RectPicInScreenAno;
	memset(RectPicInScreenAno, 0, sizeof(CRect));   //将结构体清0
	pPicWndAno->GetWindowRect(RectPicInScreenAno);

	try
	{
		//矩形规范化 底边大于顶边 右边大于左边
		RectPicInScreenAno.NormalizeRect();
		//判断鼠标是否在HalconWin内部
		if (RectPicInScreenAno.PtInRect(ptTmp))
		{
			//移动模式
			if (m_AnoWin.m_mfcHalconWinModel == MfcHalconWin::MOVE)
			{
				//左键按住会进
				if (pMsg->wParam == MK_LBUTTON)
				{
					//移动图像
					m_AnoWin.translationImage();
				}
				//左键没按住
				if (!pMsg->wParam == MK_LBUTTON)
				{
					//清理移动轨迹
					m_AnoWin.m_movedPoint.clear();
					m_AnoWin.m_movedPoint.shrink_to_fit();
				}
			}

			//更新灰度值
			HTuple Cur_Row, Cur_Col, mButton;
			HTuple Cur_Gray;
			HObject currRegion;
			m_AnoWin.getMousePosition(Cur_Row, Cur_Col, mButton);
			try
			{
				//得到灰度值
				HalconCpp::GetGrayval(m_AnoWin._mobjs.at(0), Cur_Row, Cur_Col, &Cur_Gray);
				m_anoImageGray = Cur_Gray[0].I();
			}
			catch (const std::exception&)
			{
				m_anoImageGray = -1;
			}
			UpdateData(false); //变量值同步到控件
		}
	}
	catch (...)
	{
	}

	//结果图
	CWnd* pPicWndRes = GetDlgItem(IDC_RESULTWIN);
	CRect RectPicInScreenRes;
	memset(RectPicInScreenRes, 0, sizeof(CRect));   //将结构体清0
	pPicWndRes->GetWindowRect(RectPicInScreenRes);

	try
	{
		//矩形规范化 底边大于顶边 右边大于左边
		RectPicInScreenRes.NormalizeRect();
		//判断鼠标是否在HalconWin内部
		if (RectPicInScreenRes.PtInRect(ptTmp))
		{
			//左键按住会进
			if (pMsg->wParam == MK_LBUTTON)
			{
				//移动图像
				m_ResultWin.translationImage();
			}
			//左键没按住
			if (!pMsg->wParam == MK_LBUTTON)
			{
				//清理移动轨迹
				m_ResultWin.m_movedPoint.clear();
				m_ResultWin.m_movedPoint.shrink_to_fit();
			}

			//判断鼠标是否点中了区域
			HTuple Cur_Row, Cur_Col, mButton;
			HTuple Cur_Gray;
			HObject currRegion;
			m_ResultWin.getMousePosition(Cur_Row, Cur_Col, mButton);
			if (mButton == 1)
			{
				//左键按下 鼠标在区域上
				bool flag = m_ResultWin.isPointInRegion(Cur_Row, Cur_Col, currRegion);
				if (flag)
				{
					//如果鼠标在区域上
					HTuple a, r, c;
					HalconCpp::AreaCenter(currRegion, &a, &r, &c);
					m_area = (int)a[0].D();
				}
			}
			UpdateData(false); //变量值同步到控件
		}
	}
	catch (...)
	{
	}
	return 0;
}

BOOL AIParamDebug::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
{
	try
	{
		////当前鼠标位置
		CWnd* pPICWnd = GetDlgItem(IDC_ORIWIN);
		CRect RectWindow;
		memset(RectWindow, 0, sizeof(CRect));
		pPICWnd->GetWindowRect(RectWindow);//控件在屏幕坐标							
		//矩形规范化
		RectWindow.NormalizeRect();
		if (RectWindow.PtInRect(pt) && m_oriWin.isInitImage())//判断鼠标是否在控件内部
		{
			//缩放图像
			if (zDelta >= 0)
			{
				m_oriWin.zoomImage(true);
			}
			else
			{
				m_oriWin.zoomImage(false);
			}
		}
	}
	catch (...)
	{

	}

	try
	{
		////当前鼠标位置
		CWnd* pPICWnd = GetDlgItem(IDC_ANOWIN);
		CRect RectWindow;
		memset(RectWindow, 0, sizeof(CRect));
		pPICWnd->GetWindowRect(RectWindow);//控件在屏幕坐标							
		//矩形规范化
		RectWindow.NormalizeRect();
		if (RectWindow.PtInRect(pt) && m_AnoWin.isInitImage())//判断鼠标是否在控件内部
		{
			//缩放图像
			if (zDelta >= 0)
			{
				m_AnoWin.zoomImage(true);
			}
			else
			{
				m_AnoWin.zoomImage(false);
			}
		}
	}
	catch (...)
	{

	}

	try
	{
		////当前鼠标位置
		CWnd* pPICWnd = GetDlgItem(IDC_RESULTWIN);
		CRect RectWindow;
		memset(RectWindow, 0, sizeof(CRect));
		pPICWnd->GetWindowRect(RectWindow);//控件在屏幕坐标							
		//矩形规范化
		RectWindow.NormalizeRect();
		if (RectWindow.PtInRect(pt) && m_ResultWin.isInitImage())//判断鼠标是否在控件内部
		{
			//缩放图像
			if (zDelta >= 0)
			{
				m_ResultWin.zoomImage(true);
			}
			else
			{
				m_ResultWin.zoomImage(false);
			}
		}
	}
	catch (...)
	{

	}
	return 0;
}

//下一张
void AIParamDebug::OnBnClickedButtonnext()
{
	// TODO: 在此添加控件通知处理程序代码
		// TODO: 在此添加控件通知处理程序代码
	int startendflag;
	HTuple path = MfcHalconWin::ReadImages(1, startendflag);
	HalconCpp::ReadImage(&img, path);
	m_oriWin.dispObj(img);
	m_oriWin.flushWindow();

	CString imageNumText;
	imageNumText.Format("%d/%d", MfcHalconWin::m_currentImageIndex + 1, MfcHalconWin::m_currentImageSize);
	GetDlgItem(IDC_TEXT)->SetWindowTextA(imageNumText);

	detect();
	
	if (startendflag == 1)
	{
		//最后一张了
		GetDlgItem(IDC_BUTTONNEXT)->EnableWindow(FALSE);
		GetDlgItem(IDC_BUTTONPREVIOUS)->EnableWindow(TRUE);
		return;
	}
	else
	{
		GetDlgItem(IDC_BUTTONNEXT)->EnableWindow(TRUE);
		GetDlgItem(IDC_BUTTONPREVIOUS)->EnableWindow(TRUE);
	}

}

//上一张
void AIParamDebug::OnBnClickedButtonprevious()
{
	// TODO: 在此添加控件通知处理程序代码
	int startendflag;
	HTuple path = MfcHalconWin::ReadImages(-1, startendflag);
	HalconCpp::ReadImage(&img, path);
	m_oriWin.dispObj(img);
	m_oriWin.flushWindow();

	detect();

	CString imageNumText;
	imageNumText.Format("%d/%d", MfcHalconWin::m_currentImageIndex + 1, MfcHalconWin::m_currentImageSize);
	GetDlgItem(IDC_TEXT)->SetWindowTextA(imageNumText);

	if (startendflag == -1)
	{
		//最前一张了
		GetDlgItem(IDC_BUTTONPREVIOUS)->EnableWindow(FALSE);
		GetDlgItem(IDC_BUTTONNEXT)->EnableWindow(TRUE);
		return;
	}
	else
	{
		GetDlgItem(IDC_BUTTONPREVIOUS)->EnableWindow(TRUE);
		GetDlgItem(IDC_BUTTONNEXT)->EnableWindow(TRUE);
	}
}


void AIParamDebug::OnBnClickedRadio1()
{
	// TODO: 在此添加控件通知处理程序代码
	isFront = true;
	LoadAnoParams(true);
}

//反面
void AIParamDebug::OnBnClickedRadio7()
{
	// TODO: 在此添加控件通知处理程序代码
	isFront = false;
	LoadAnoParams(false);
}


void AIParamDebug::OnBnClickedButtonSaveparam()
{
	// TODO: 在此添加控件通知处理程序代码
	CDefectInspectionSystemDlg* pDia = CDefectInspectionSystemDlg::s_pDialog;
	CString str;
	int tempInt;
	if (isFront)
	{
		//正面
		GetDlgItemText(IDC_EDIT_DEF_THRESH, str);
		WritePrivateProfileString("DFront", "ABN_DEF_Thresh", str, theApp.m_strFilePath + "\\System-" + pDia->m_strCurrentCupType + ".ini");
		tempInt = std::atoi(str);
		pDia->m_paramDetect_Front.ABN_DEF_Thresh = tempInt;

		GetDlgItemText(IDC_EDITSingleBigArea, str);
		WritePrivateProfileString("DFront", "ABN_Single_Big_Area", str, theApp.m_strFilePath + "\\System-" + pDia->m_strCurrentCupType + ".ini");
		tempInt = std::atoi(str);
		pDia->m_paramDetect_Front.ABN_Single_Big_Area = tempInt;

		GetDlgItemText(IDC_EDITSingleArea, str);
		WritePrivateProfileString("DFront", "ABN_Single_Area", str, theApp.m_strFilePath + "\\System-" + pDia->m_strCurrentCupType + ".ini");
		tempInt = std::atoi(str);
		pDia->m_paramDetect_Front.ABN_Single_Area = tempInt;

		GetDlgItemText(IDC_EDIT_ALL_Area, str);
		WritePrivateProfileString("DFront", "ABN_ALL_AREA", str, theApp.m_strFilePath + "\\System-" + pDia->m_strCurrentCupType + ".ini");
		tempInt = std::atoi(str);
		pDia->m_paramDetect_Front.ABN_ALL_Area = tempInt;

		GetDlgItemText(IDC_EDIT_AiErosion, str);
		WritePrivateProfileString("DFront", "AiErosion", str, theApp.m_strFilePath + "\\System-" + pDia->m_strCurrentCupType + ".ini");
		tempInt = std::atoi(str);
		pDia->m_paramDetect_Front.AiErsion = tempInt;
	}
	else
	{
		//反面
		GetDlgItemText(IDC_EDIT_DEF_THRESH, str);
		WritePrivateProfileString("DBack", "ABN_DEF_Thresh", str, theApp.m_strFilePath + "\\System-" + pDia->m_strCurrentCupType + ".ini");
		tempInt = std::atoi(str);
		pDia->m_paramDetect_Back.ABN_DEF_Thresh = tempInt;

		GetDlgItemText(IDC_EDITSingleBigArea, str);
		WritePrivateProfileString("DBack", "ABN_Single_Big_Area", str, theApp.m_strFilePath + "\\System-" + pDia->m_strCurrentCupType + ".ini");
		tempInt = std::atoi(str);
		pDia->m_paramDetect_Back.ABN_Single_Big_Area = tempInt;

		GetDlgItemText(IDC_EDITSingleArea, str);
		WritePrivateProfileString("DBack", "ABN_Single_Area", str, theApp.m_strFilePath + "\\System-" + pDia->m_strCurrentCupType + ".ini");
		tempInt = std::atoi(str);
		pDia->m_paramDetect_Back.ABN_Single_Area = tempInt;

		GetDlgItemText(IDC_EDIT_ALL_Area, str);
		WritePrivateProfileString("DBack", "ABN_ALL_AREA", str, theApp.m_strFilePath + "\\System-" + pDia->m_strCurrentCupType + ".ini");
		tempInt = std::atoi(str);
		pDia->m_paramDetect_Back.ABN_ALL_Area = tempInt;

		GetDlgItemText(IDC_EDIT_AiErosion, str);
		WritePrivateProfileString("DBack", "AiErosion", str, theApp.m_strFilePath + "\\System-" + pDia->m_strCurrentCupType + ".ini");
		tempInt = std::atoi(str);
		pDia->m_paramDetect_Back.AiErsion = tempInt;
	}
}


void AIParamDebug::OnBnClickedButton1()
{
	// TODO: 在此添加控件通知处理程序代码
	m_oriWin.m_mfcHalconWinModel = MfcHalconWin::SELECT;
}


void AIParamDebug::OnBnClickedButton22()
{
	// TODO: 在此添加控件通知处理程序代码
	m_oriWin.m_mfcHalconWinModel = MfcHalconWin::MOVE;
}


void AIParamDebug::OnBnClickedButton23()
{
	// TODO: 在此添加控件通知处理程序代码
	m_oriWin.adaptWindow();
}


void AIParamDebug::OnBnClickedButton24()
{
	// TODO: 在此添加控件通知处理程序代码
	m_AnoWin.m_mfcHalconWinModel = MfcHalconWin::SELECT;
}


void AIParamDebug::OnBnClickedButton25()
{
	// TODO: 在此添加控件通知处理程序代码
	m_AnoWin.m_mfcHalconWinModel = MfcHalconWin::MOVE;
}


void AIParamDebug::OnBnClickedButton26()
{
	// TODO: 在此添加控件通知处理程序代码
	m_AnoWin.adaptWindow();
}


void AIParamDebug::OnBnClickedButton27()
{
	// TODO: 在此添加控件通知处理程序代码
	m_ResultWin.m_mfcHalconWinModel = MfcHalconWin::SELECT;
}


void AIParamDebug::OnBnClickedButton28()
{
	// TODO: 在此添加控件通知处理程序代码
	m_ResultWin.m_mfcHalconWinModel = MfcHalconWin::MOVE;
}


void AIParamDebug::OnBnClickedButton29()
{
	// TODO: 在此添加控件通知处理程序代码
	m_ResultWin.adaptWindow();
}
